
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
</head>
<body>


<form action="" method="post">
    <label for="username">用户名</label>
    <input type="text" id="userName" name="userName" ><br>
    <label for="password">密码</label>
    <input type="password" id="password" name="password"><br>
    <input type="submit" value="提交">

</form>
<button onclick="submit()">ajax提交</button>
<p id="msg"></p>
<script>
    function submit(){
        let userName = $('#userName').val();
        let password = $('#password').val();
        $.ajax({
            url:"loginAjax",
            type:"post",
            data:{'userName':userName,'password':password},
            success:function (data){
                console.log(data);
                $('#msg').text(data);
            },
        });
    }
</script>

<br/>
<a href="hello-servlet">Hello Servlet</a>
</body>
</html>